VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOEmpleado"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private mvarConnection As utilConexion 'local copy

Public Property Set Connection(ByVal vdata As utilConexion)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.Connection = vData
    Set mvarConnection = vdata
End Property

'---------------------------------------------------------------------------------------
' Procedure : getLista
' DateTime  : 23/06/2008 18:02
' Author    : fdamiani
' Purpose   :
'---------------------------------------------------------------------------------------
'
Public Function getLista(bean As bempleado) As Collection
'On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As bempleado

sql = "SELECT ncodigo ,snombres , sapellidos, snomcorto, nestado , sdescripcion, sCodBarra "
sql = sql + "FROM proc_empleado_select(" + CStr(bean.bEstado.nCodigo) + ");"

rst.Open sql, mvarConnection.Connection, adOpenForwardOnly

While Not rst.EOF
    Set record = New bempleado
    If Not IsNull(rst.Fields("ncodigo")) Then record.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("snombres")) Then record.sNombres = rst.Fields("snombres").value
    If Not IsNull(rst.Fields("sapellidos")) Then record.sApellidos = rst.Fields("sapellidos").value
    If Not IsNull(rst.Fields("snomcorto")) Then record.sNombreCorto = rst.Fields("snomcorto").value
    If Not IsNull(rst.Fields("nestado")) Then record.bEstado.nCodigo = rst.Fields("nestado").value
    If Not IsNull(rst.Fields("sdescripcion")) Then record.bEstado.sDescripcion = rst.Fields("sdescripcion").value
    If Not IsNull(rst.Fields("sCodBarra")) Then record.sCodBarra = rst.Fields("sCodBarra").value
    rst.MoveNext
    list.Add record
Wend
Set getLista = list

hnderr:
If Err.Number = 0 Then Exit Function
cloneError Err
End Function



'---------------------------------------------------------------------------------------
' Procedure : guardarNuevo
' DateTime  : 23/06/2008 18:02
' Author    : fdamiani
' Purpose   :
'---------------------------------------------------------------------------------------
'
Public Function guardarNuevo(bean As bempleado) As Integer
On Error GoTo hnderr
Dim rst As Recordset
Dim sql As String
sql = "select * from proc_empleado_insert('" + bean.sNombres + "','"
sql = sql + bean.sApellidos + "','" + bean.sNombreCorto + "'," + CStr(bean.bEstado.nCodigo) + ",'"
sql = sql + bean.sCodBarra + "')"
Set rst = mvarConnection.Connection.Execute(sql)
guardarNuevo = UtilConstantes.OPT_DATOS_GUARDADOS
hnderr:
If Err.Number = 0 Then Exit Function
guardarNuevo = UtilConstantes.OPT_ERROR_ENCONTRADO
cloneError Err
Err.Clear
End Function

'---------------------------------------------------------------------------------------
' Procedure : actualizar
' DateTime  : 23/06/2008 18:02
' Author    : fdamiani
' Purpose   :
'---------------------------------------------------------------------------------------
'
Public Function actualizar(bean As bempleado) As Integer
On Error GoTo hnderr
Dim sql As String
sql = "select * from proc_empleado_update('" + bean.sNombres + "','"
sql = sql + bean.sApellidos + "','" + bean.sNombreCorto + "'," + CStr(bean.bEstado.nCodigo) + ",'"
sql = sql + bean.sCodBarra + "'," + CStr(bean.nCodigo) + ")"
mvarConnection.Connection.Execute sql
actualizar = UtilConstantes.OPT_DATOS_GUARDADOS
hnderr:
If Err.Number = 0 Then Exit Function
actualizar = UtilConstantes.OPT_ERROR_ENCONTRADO
cloneError Err
Err.Clear
End Function
